package com.yhh.college_information_platform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yhh.college_information_platform.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 评论Mapper
 *
 * @author yhh
 * @date 2025-10-26
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    
    /**
     * 增加评论点赞数
     */
    @Update("UPDATE t_comment SET like_count = like_count + 1 WHERE id = #{commentId}")
    int incrementLikeCount(@Param("commentId") Long commentId);
    
    /**
     * 减少评论点赞数
     */
    @Update("UPDATE t_comment SET like_count = like_count - 1 WHERE id = #{commentId} AND like_count > 0")
    int decrementLikeCount(@Param("commentId") Long commentId);
}

